<template>
  <div class="p-15px">
    <wd-form ref="formRef" :model="model" errorType="toast">
      <wd-cell-group :border="true">
        <wd-input
          v-model="model.taskName"
          type="text"
          label="任务名称"
          prop="taskName"
          placeholder="请输入任务名称(选填)"
          @change="handleChange"
        />
        <wd-textarea
          v-model="model.content"
          prop="content"
          placeholder="这一刻的想法..."
          :rules="getRule('请输入内容')"
        />
        <wd-upload
          v-model:file-list="fileList"
          prop="avatar"
          image-mode="aspectFill"
          :action="action"
          multiple
          @change="handleChange"
        />
        <wd-cell
          prop="tag"
          class="mb-2"
          title="标签"
          title-width="60px"
          center
          :rules="getRule('请选择分类标签')"
        >
          <DynamicTags v-model:value="model.tag" prop="tag" />
        </wd-cell>
        <wd-datetime-picker
          v-model="model.date"
          label="日期"
          type="date"
          prop="date"
          :min-date="startDate"
          :max-date="endDate"
          :rules="getRule('请选择日期')"
        />
        <wd-datetime-picker
          v-model="model.time"
          prop="time"
          label="时间"
          type="time"
          :rules="getRule('请选择时间')"
        />

        <!-- <wd-input
          v-model="model.count"
          label="发送天数"
          label-width="100px"
          prop="count"
          type="number"
          placeholder="请输入发送天数"
        />

        <wd-input
          v-model="model.interval"
          label="间隔天数"
          label-width="100px"
          prop="interval"
          type="number"
          placeholder="请输入间隔天数"
        /> -->

        <wd-cell title="设置为模板" center clickable @click="handleCheck">
          <view @click.stop="noop">
            <wd-checkbox
              ref="checkBox"
              v-model="model.isTemplate"
              custom-style="margin:0;"
            />
          </view>
        </wd-cell>

        <wd-button
          type="primary"
          custom-class="mt-16px"
          size="large"
          block
          @click="handleSubmit"
        >
          保存为草稿
        </wd-button>
      </wd-cell-group>
    </wd-form>
  </div>
  <wd-toast />
  <wd-message-box />
</template>

<script setup lang="ts">
import DynamicTags from '@/components/DynamicTags/index.vue';
import { useDraftEdit } from '@/composables';
const {
  startDate,
  endDate,
  fileList,
  formRef,
  model,
  action,
  getRule,
  handleCheck,
  handleChange,
  noop,
  handleSubmit
} = useDraftEdit();
</script>

<style lang="scss" scoped></style>
